#ifndef __EKF_VMEM_H__
#define __EKF_VMEM_H__

/* control the temp page for current kstack */
void        *ekf_set_tpage(physaddr_t addr);

/* simple function for getting and setting the current vpt */
void         ekf_vpt_set(void *vaddr, uint32_t pte);
ptab_entry_t ekf_vpt_get(void *vaddr);

void ekf_mmap_set(void *vaddr, physaddr_t paddr,  int write, int user);
void ekf_mmap_get(void *vaddr, physaddr_t *paddr, int *write, int *user);

/* These macros define a simple method for using tpage space,
   all the data should not exceed the 4K page boundary */
#define EKF_BEGIN_TPAGE(ADDR, VAR)					  \
	 { uint32_t __old = vpt_get((void *)KTMP);	\
	   VAR = set_tpage(ADDR)

#define EKF_EXIT_TPAGE vpt_set((void *)KTMP, __old)
#define EKF_END_TPAGE  vpt_set((void *)KTMP, __old); }

/* a universe function for vpt management */
#define    FA_COW 1
#define	   FA_AWA 2
#define    ekf_fix_addr(args ...) ekf___fix_addr(0, args)
int        ekf___fix_addr(int verbose, void *addr, ptab_entry_t *create, ...);

/* Create a new sketch vpt */
physaddr_t ekf_vmem_vpt_new(int new_share);

#endif
